From 9acc941959dfb420645e8ba033a2b15ce0821c16 Mon Sep 17 00:00:00 2001 From: Jody Goldberg Date: Fri, 2 Jan 2004 23:14:28 +0000 Subject: [PATCH] add visible_horizontal, visible_vertical. (gtk_action_class_init) : here. 2004-01-01 Jody Goldberg * gtk/gtkaction.c (_GtkActionPrivate) : add visible_horizontal, visible_vertical. (gtk_action_class_init) : here. (gtk_action_init) : here. (gtk_action_set_property) : here. (gtk_action_get_property) : here. (connect_proxy) : and here. 2003-12-30 Jody Goldberg * gtk/gtkactiongroup.c (gtk_action_group_add_action_with_accel) : new utility routine for use in derived GtkActions with the replicated code from. (gtk_action_group_add_actions_full) : here. (gtk_action_group_add_toggle_actions_full) : here. (gtk_action_group_add_radio_actions_full) : and here. 2003-12-24 Jody Goldberg * gtk/gtkactiongroup.h : Add some const to the char * in GtkActionEntry*. We're reccomending people pass static strings to them, and not freeing them. This stems to flood of warnings that result. * gtk/gtkactiongroup.c (gtk_action_group_add_actions_full) : change temp vars to const to match above. (gtk_action_group_add_toggle_actions_full) : ditto. (gtk_action_group_add_radio_actions_full) : ditto. --- ChangeLog | 44 ++++++++++--- ChangeLog.pre-2-10 | 44 ++++++++++--- ChangeLog.pre-2-4 | 44 ++++++++++--- ChangeLog.pre-2-6 | 44 ++++++++++--- ChangeLog.pre-2-8 | 44 ++++++++++--- gtk/gtkaction.c | 40 ++++++++++++ gtk/gtkactiongroup.c | 147 ++++++++++++++++++++----------------------- gtk/gtkactiongroup.h | 36 ++++++----- 8 files changed, 314 insertions(+), 129 deletions(-) diff --git a/ChangeLog b/ChangeLog index 168baf2c6a..fdd274ab46 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +2004-01-01 Jody Goldberg + + * gtk/gtkaction.c (_GtkActionPrivate) : add visible_horizontal, + visible_vertical. + (gtk_action_class_init) : here. + (gtk_action_init) : here. + (gtk_action_set_property) : here. + (gtk_action_get_property) : here. + (connect_proxy) : and here. + +2003-12-30 Jody Goldberg + + * gtk/gtkactiongroup.c (gtk_action_group_add_action_with_accel) : new + utility routine for use in derived GtkActions with the replicated code + from. + (gtk_action_group_add_actions_full) : here. + (gtk_action_group_add_toggle_actions_full) : here. + (gtk_action_group_add_radio_actions_full) : and here. + 2004-01-01 Taneem Ahmed * configure.in: Added "bn" to ALL_LINGUAS. @@ -17,7 +36,7 @@ Fri Jan 2 02:50:11 2004 Matthias Clasen 2003-12-31 13:49 Daniel Rogers - * gdk/x11/gdkinput-x11.c: (gdk_input_translate_coordinates) + * gdk/x11/gdkinput-x11.c: (gdk_input_translate_coordinates) Fix to allow reasonable pointer behavior in window mode when an extended input device reports an incorrect resolution of 0. Fixes @@ -102,6 +121,17 @@ Tue Dec 23 22:34:50 2003 Manish Singh * gtk/gtkicontheme.h: fix GTK_TYPE_ICON_INFO macro, reported by muppet. +2003-12-24 Jody Goldberg + + * gtk/gtkactiongroup.h : Add some const to the char * in + GtkActionEntry*. We're reccomending people pass static strings to + them, and not freeing them. This stems to flood of warnings that + result. + * gtk/gtkactiongroup.c (gtk_action_group_add_actions_full) : change + temp vars to const to match above. + (gtk_action_group_add_toggle_actions_full) : ditto. + (gtk_action_group_add_radio_actions_full) : ditto. + Wed Dec 24 01:12:53 2003 Matthias Clasen * gtk/gtkclipboard.[hc]: Add GtkClipboardTargetReceivedFunc, @@ -384,12 +414,12 @@ Wed Dec 17 21:23:01 2003 Kristian Rietveld 2003-12-07 Murray Cumming - * gtk/gtktreemodel.c: - (row_inserted_marshal, row_deleted_marshal, rows_reorderered_marshal) - Actually call the default signal handlers instead of calling the - marshallers themselves in an endless loop. These default signal handler - callbacks are not actually set so this is only noticed by gtkmm at - the moment. Bug 123923. + * gtk/gtktreemodel.c: + (row_inserted_marshal, row_deleted_marshal, rows_reorderered_marshal) + Actually call the default signal handlers instead of calling the + marshallers themselves in an endless loop. These default signal handler + callbacks are not actually set so this is only noticed by gtkmm at + the moment. Bug 123923. 2003-12-16 Federico Mena Quintero diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 168baf2c6a..fdd274ab46 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,22 @@ +2004-01-01 Jody Goldberg + + * gtk/gtkaction.c (_GtkActionPrivate) : add visible_horizontal, + visible_vertical. + (gtk_action_class_init) : here. + (gtk_action_init) : here. + (gtk_action_set_property) : here. + (gtk_action_get_property) : here. + (connect_proxy) : and here. + +2003-12-30 Jody Goldberg + + * gtk/gtkactiongroup.c (gtk_action_group_add_action_with_accel) : new + utility routine for use in derived GtkActions with the replicated code + from. + (gtk_action_group_add_actions_full) : here. + (gtk_action_group_add_toggle_actions_full) : here. + (gtk_action_group_add_radio_actions_full) : and here. + 2004-01-01 Taneem Ahmed * configure.in: Added "bn" to ALL_LINGUAS. @@ -17,7 +36,7 @@ Fri Jan 2 02:50:11 2004 Matthias Clasen 2003-12-31 13:49 Daniel Rogers - * gdk/x11/gdkinput-x11.c: (gdk_input_translate_coordinates) + * gdk/x11/gdkinput-x11.c: (gdk_input_translate_coordinates) Fix to allow reasonable pointer behavior in window mode when an extended input device reports an incorrect resolution of 0. Fixes @@ -102,6 +121,17 @@ Tue Dec 23 22:34:50 2003 Manish Singh * gtk/gtkicontheme.h: fix GTK_TYPE_ICON_INFO macro, reported by muppet. +2003-12-24 Jody Goldberg + + * gtk/gtkactiongroup.h : Add some const to the char * in + GtkActionEntry*. We're reccomending people pass static strings to + them, and not freeing them. This stems to flood of warnings that + result. + * gtk/gtkactiongroup.c (gtk_action_group_add_actions_full) : change + temp vars to const to match above. + (gtk_action_group_add_toggle_actions_full) : ditto. + (gtk_action_group_add_radio_actions_full) : ditto. + Wed Dec 24 01:12:53 2003 Matthias Clasen * gtk/gtkclipboard.[hc]: Add GtkClipboardTargetReceivedFunc, @@ -384,12 +414,12 @@ Wed Dec 17 21:23:01 2003 Kristian Rietveld 2003-12-07 Murray Cumming - * gtk/gtktreemodel.c: - (row_inserted_marshal, row_deleted_marshal, rows_reorderered_marshal) - Actually call the default signal handlers instead of calling the - marshallers themselves in an endless loop. These default signal handler - callbacks are not actually set so this is only noticed by gtkmm at - the moment. Bug 123923. + * gtk/gtktreemodel.c: + (row_inserted_marshal, row_deleted_marshal, rows_reorderered_marshal) + Actually call the default signal handlers instead of calling the + marshallers themselves in an endless loop. These default signal handler + callbacks are not actually set so this is only noticed by gtkmm at + the moment. Bug 123923. 2003-12-16 Federico Mena Quintero diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 168baf2c6a..fdd274ab46 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,22 @@ +2004-01-01 Jody Goldberg + + * gtk/gtkaction.c (_GtkActionPrivate) : add visible_horizontal, + visible_vertical. + (gtk_action_class_init) : here. + (gtk_action_init) : here. + (gtk_action_set_property) : here. + (gtk_action_get_property) : here. + (connect_proxy) : and here. + +2003-12-30 Jody Goldberg + + * gtk/gtkactiongroup.c (gtk_action_group_add_action_with_accel) : new + utility routine for use in derived GtkActions with the replicated code + from. + (gtk_action_group_add_actions_full) : here. + (gtk_action_group_add_toggle_actions_full) : here. + (gtk_action_group_add_radio_actions_full) : and here. + 2004-01-01 Taneem Ahmed * configure.in: Added "bn" to ALL_LINGUAS. @@ -17,7 +36,7 @@ Fri Jan 2 02:50:11 2004 Matthias Clasen 2003-12-31 13:49 Daniel Rogers - * gdk/x11/gdkinput-x11.c: (gdk_input_translate_coordinates) + * gdk/x11/gdkinput-x11.c: (gdk_input_translate_coordinates) Fix to allow reasonable pointer behavior in window mode when an extended input device reports an incorrect resolution of 0. Fixes @@ -102,6 +121,17 @@ Tue Dec 23 22:34:50 2003 Manish Singh * gtk/gtkicontheme.h: fix GTK_TYPE_ICON_INFO macro, reported by muppet. +2003-12-24 Jody Goldberg + + * gtk/gtkactiongroup.h : Add some const to the char * in + GtkActionEntry*. We're reccomending people pass static strings to + them, and not freeing them. This stems to flood of warnings that + result. + * gtk/gtkactiongroup.c (gtk_action_group_add_actions_full) : change + temp vars to const to match above. + (gtk_action_group_add_toggle_actions_full) : ditto. + (gtk_action_group_add_radio_actions_full) : ditto. + Wed Dec 24 01:12:53 2003 Matthias Clasen * gtk/gtkclipboard.[hc]: Add GtkClipboardTargetReceivedFunc, @@ -384,12 +414,12 @@ Wed Dec 17 21:23:01 2003 Kristian Rietveld 2003-12-07 Murray Cumming - * gtk/gtktreemodel.c: - (row_inserted_marshal, row_deleted_marshal, rows_reorderered_marshal) - Actually call the default signal handlers instead of calling the - marshallers themselves in an endless loop. These default signal handler - callbacks are not actually set so this is only noticed by gtkmm at - the moment. Bug 123923. + * gtk/gtktreemodel.c: + (row_inserted_marshal, row_deleted_marshal, rows_reorderered_marshal) + Actually call the default signal handlers instead of calling the + marshallers themselves in an endless loop. These default signal handler + callbacks are not actually set so this is only noticed by gtkmm at + the moment. Bug 123923. 2003-12-16 Federico Mena Quintero diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 168baf2c6a..fdd274ab46 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,22 @@ +2004-01-01 Jody Goldberg + + * gtk/gtkaction.c (_GtkActionPrivate) : add visible_horizontal, + visible_vertical. + (gtk_action_class_init) : here. + (gtk_action_init) : here. + (gtk_action_set_property) : here. + (gtk_action_get_property) : here. + (connect_proxy) : and here. + +2003-12-30 Jody Goldberg + + * gtk/gtkactiongroup.c (gtk_action_group_add_action_with_accel) : new + utility routine for use in derived GtkActions with the replicated code + from. + (gtk_action_group_add_actions_full) : here. + (gtk_action_group_add_toggle_actions_full) : here. + (gtk_action_group_add_radio_actions_full) : and here. + 2004-01-01 Taneem Ahmed * configure.in: Added "bn" to ALL_LINGUAS. @@ -17,7 +36,7 @@ Fri Jan 2 02:50:11 2004 Matthias Clasen 2003-12-31 13:49 Daniel Rogers - * gdk/x11/gdkinput-x11.c: (gdk_input_translate_coordinates) + * gdk/x11/gdkinput-x11.c: (gdk_input_translate_coordinates) Fix to allow reasonable pointer behavior in window mode when an extended input device reports an incorrect resolution of 0. Fixes @@ -102,6 +121,17 @@ Tue Dec 23 22:34:50 2003 Manish Singh * gtk/gtkicontheme.h: fix GTK_TYPE_ICON_INFO macro, reported by muppet. +2003-12-24 Jody Goldberg + + * gtk/gtkactiongroup.h : Add some const to the char * in + GtkActionEntry*. We're reccomending people pass static strings to + them, and not freeing them. This stems to flood of warnings that + result. + * gtk/gtkactiongroup.c (gtk_action_group_add_actions_full) : change + temp vars to const to match above. + (gtk_action_group_add_toggle_actions_full) : ditto. + (gtk_action_group_add_radio_actions_full) : ditto. + Wed Dec 24 01:12:53 2003 Matthias Clasen * gtk/gtkclipboard.[hc]: Add GtkClipboardTargetReceivedFunc, @@ -384,12 +414,12 @@ Wed Dec 17 21:23:01 2003 Kristian Rietveld 2003-12-07 Murray Cumming - * gtk/gtktreemodel.c: - (row_inserted_marshal, row_deleted_marshal, rows_reorderered_marshal) - Actually call the default signal handlers instead of calling the - marshallers themselves in an endless loop. These default signal handler - callbacks are not actually set so this is only noticed by gtkmm at - the moment. Bug 123923. + * gtk/gtktreemodel.c: + (row_inserted_marshal, row_deleted_marshal, rows_reorderered_marshal) + Actually call the default signal handlers instead of calling the + marshallers themselves in an endless loop. These default signal handler + callbacks are not actually set so this is only noticed by gtkmm at + the moment. Bug 123923. 2003-12-16 Federico Mena Quintero diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 168baf2c6a..fdd274ab46 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,22 @@ +2004-01-01 Jody Goldberg + + * gtk/gtkaction.c (_GtkActionPrivate) : add visible_horizontal, + visible_vertical. + (gtk_action_class_init) : here. + (gtk_action_init) : here. + (gtk_action_set_property) : here. + (gtk_action_get_property) : here. + (connect_proxy) : and here. + +2003-12-30 Jody Goldberg + + * gtk/gtkactiongroup.c (gtk_action_group_add_action_with_accel) : new + utility routine for use in derived GtkActions with the replicated code + from. + (gtk_action_group_add_actions_full) : here. + (gtk_action_group_add_toggle_actions_full) : here. + (gtk_action_group_add_radio_actions_full) : and here. + 2004-01-01 Taneem Ahmed * configure.in: Added "bn" to ALL_LINGUAS. @@ -17,7 +36,7 @@ Fri Jan 2 02:50:11 2004 Matthias Clasen 2003-12-31 13:49 Daniel Rogers - * gdk/x11/gdkinput-x11.c: (gdk_input_translate_coordinates) + * gdk/x11/gdkinput-x11.c: (gdk_input_translate_coordinates) Fix to allow reasonable pointer behavior in window mode when an extended input device reports an incorrect resolution of 0. Fixes @@ -102,6 +121,17 @@ Tue Dec 23 22:34:50 2003 Manish Singh * gtk/gtkicontheme.h: fix GTK_TYPE_ICON_INFO macro, reported by muppet. +2003-12-24 Jody Goldberg + + * gtk/gtkactiongroup.h : Add some const to the char * in + GtkActionEntry*. We're reccomending people pass static strings to + them, and not freeing them. This stems to flood of warnings that + result. + * gtk/gtkactiongroup.c (gtk_action_group_add_actions_full) : change + temp vars to const to match above. + (gtk_action_group_add_toggle_actions_full) : ditto. + (gtk_action_group_add_radio_actions_full) : ditto. + Wed Dec 24 01:12:53 2003 Matthias Clasen * gtk/gtkclipboard.[hc]: Add GtkClipboardTargetReceivedFunc, @@ -384,12 +414,12 @@ Wed Dec 17 21:23:01 2003 Kristian Rietveld 2003-12-07 Murray Cumming - * gtk/gtktreemodel.c: - (row_inserted_marshal, row_deleted_marshal, rows_reorderered_marshal) - Actually call the default signal handlers instead of calling the - marshallers themselves in an endless loop. These default signal handler - callbacks are not actually set so this is only noticed by gtkmm at - the moment. Bug 123923. + * gtk/gtktreemodel.c: + (row_inserted_marshal, row_deleted_marshal, rows_reorderered_marshal) + Actually call the default signal handlers instead of calling the + marshallers themselves in an endless loop. These default signal handler + callbacks are not actually set so this is only noticed by gtkmm at + the moment. Bug 123923. 2003-12-16 Federico Mena Quintero diff --git a/gtk/gtkaction.c b/gtk/gtkaction.c index 19730370f6..b0db28361a 100644 --- a/gtk/gtkaction.c +++ b/gtk/gtkaction.c @@ -59,6 +59,8 @@ struct _GtkActionPrivate guint visible : 1; guint label_set : 1; /* these two used so we can set label */ guint short_label_set : 1; /* based on stock id */ + guint visible_horizontal : 1; + guint visible_vertical : 1; guint is_important : 1; guint hide_if_empty : 1; @@ -88,6 +90,8 @@ enum PROP_SHORT_LABEL, PROP_TOOLTIP, PROP_STOCK_ID, + PROP_VISIBLE_HORIZONTAL, + PROP_VISIBLE_VERTICAL, PROP_IS_IMPORTANT, PROP_HIDE_IF_EMPTY, PROP_SENSITIVE, @@ -215,6 +219,20 @@ gtk_action_class_init (GtkActionClass *klass) _("The stock icon displayed in widgets representing this action."), NULL, G_PARAM_READWRITE)); + g_object_class_install_property (gobject_class, + PROP_VISIBLE_HORIZONTAL, + g_param_spec_boolean ("visible_horizontal", + _("Visible when horizontal"), + _("Whether the toolbar item is visible when the toolbar is in a horizontal orientation."), + TRUE, + G_PARAM_READWRITE)); + g_object_class_install_property (gobject_class, + PROP_VISIBLE_VERTICAL, + g_param_spec_boolean ("visible_vertical", + _("Visible when vertical"), + _("Whether the toolbar item is visible when the toolbar is in a vertical orientation."), + TRUE, + G_PARAM_READWRITE)); g_object_class_install_property (gobject_class, PROP_IS_IMPORTANT, g_param_spec_boolean ("is_important", @@ -315,6 +333,8 @@ gtk_action_init (GtkAction *action) action->private_data->short_label = NULL; action->private_data->tooltip = NULL; action->private_data->stock_id = NULL; + action->private_data->visible_horizontal = TRUE; + action->private_data->visible_vertical = TRUE; action->private_data->is_important = FALSE; action->private_data->hide_if_empty = TRUE; @@ -436,6 +456,12 @@ gtk_action_set_property (GObject *object, g_object_notify (object, "short_label"); } break; + case PROP_VISIBLE_HORIZONTAL: + action->private_data->visible_horizontal = g_value_get_boolean (value); + break; + case PROP_VISIBLE_VERTICAL: + action->private_data->visible_vertical = g_value_get_boolean (value); + break; case PROP_IS_IMPORTANT: action->private_data->is_important = g_value_get_boolean (value); break; @@ -481,6 +507,12 @@ gtk_action_get_property (GObject *object, case PROP_STOCK_ID: g_value_set_string (value, action->private_data->stock_id); break; + case PROP_VISIBLE_HORIZONTAL: + g_value_set_boolean (value, action->private_data->visible_horizontal); + break; + case PROP_VISIBLE_VERTICAL: + g_value_set_boolean (value, action->private_data->visible_vertical); + break; case PROP_IS_IMPORTANT: g_value_set_boolean (value, action->private_data->is_important); break; @@ -782,6 +814,8 @@ connect_proxy (GtkAction *action, "label", action->private_data->short_label, "use_underline", TRUE, "stock_id", action->private_data->stock_id, + "visible_horizontal", action->private_data->visible_horizontal, + "visible_vertical", action->private_data->visible_vertical, "is_important", action->private_data->is_important, NULL); /* FIXME: we should set the tooltip here, but the current api @@ -793,6 +827,12 @@ connect_proxy (GtkAction *action, g_signal_connect_object (action, "notify::stock_id", G_CALLBACK (gtk_action_sync_property), proxy, 0); + g_signal_connect_object (action, "notify::visible_horizontal", + G_CALLBACK (gtk_action_sync_property), + proxy, 0); + g_signal_connect_object (action, "notify::visible_vertical", + G_CALLBACK (gtk_action_sync_property), + proxy, 0); g_signal_connect_object (action, "notify::is_important", G_CALLBACK (gtk_action_sync_property), proxy, 0); diff --git a/gtk/gtkactiongroup.c b/gtk/gtkactiongroup.c index 83768473c7..bac151efdc 100644 --- a/gtk/gtkactiongroup.c +++ b/gtk/gtkactiongroup.c @@ -293,6 +293,56 @@ gtk_action_group_add_action (GtkActionGroup *action_group, g_object_ref (action)); } +/** + * gtk_action_group_add_action_with_accel: + * @action_group: the action group (#GtkActionGroup) + * @action : the action to add (#GtkAction) + * @name : + * @accelerator : + * @stock_id : + * + * Adds an action object to the action group and sets up the accelerator. + * + * If @accelerator is NULL, attempt to use the accelerator associated with + * @stock_id. + * + * accel paths are set to + * <Actions>/group-name/action-name. + * + * Since: 2.4 + */ +void +gtk_action_group_add_action_with_accel (GtkActionGroup *action_group, + GtkAction *action, + const char *name, + const char *accelerator, + const char *stock_id) +{ + gchar *accel_path; + guint accel_key = 0; + GdkModifierType accel_mods; + GtkStockItem stock_item; + + accel_path = g_strconcat ("/", + action_group->private_data->name, "/", name, NULL); + + if (accelerator) + gtk_accelerator_parse (accelerator, &accel_key, &accel_mods); + else if (stock_id && gtk_stock_lookup (stock_id, &stock_item)) + { + accel_key = stock_item.keyval; + accel_mods = stock_item.modifier; + } + + if (accel_key) + gtk_accel_map_add_entry (accel_path, accel_key, accel_mods); + + gtk_action_set_accel_path (action, accel_path); + g_free (accel_path); + + gtk_action_group_add_action (action_group, action); +} + /** * gtk_action_group_remove_action: * @action_group: the action group @@ -412,12 +462,8 @@ gtk_action_group_add_actions_full (GtkActionGroup *action_group, for (i = 0; i < n_entries; i++) { GtkAction *action; - gchar *accel_path; - guint accel_key = 0; - GdkModifierType accel_mods; - GtkStockItem stock_item; - gchar *label; - gchar *tooltip; + const gchar *label; + const gchar *tooltip; if (translate_func) { @@ -442,26 +488,10 @@ gtk_action_group_add_actions_full (GtkActionGroup *action_group, entries[i].callback, user_data, (GClosureNotify)destroy, 0); - /* set the accel path for the menu item */ - accel_path = g_strconcat ("/", action_group->private_data->name, "/", - entries[i].name, NULL); - - if (entries[i].accelerator) - gtk_accelerator_parse (entries[i].accelerator, &accel_key, &accel_mods); - else if (entries[i].stock_id && - gtk_stock_lookup (entries[i].stock_id, &stock_item)) - { - accel_key = stock_item.keyval; - accel_mods = stock_item.modifier; - } - - if (accel_key) - gtk_accel_map_add_entry (accel_path, accel_key, accel_mods); - - gtk_action_set_accel_path (action, accel_path); - g_free (accel_path); - - gtk_action_group_add_action (action_group, action); + gtk_action_group_add_action_with_accel (action_group, action, + entries[i].name, + entries[i].accelerator, + entries[i].stock_id); g_object_unref (action); } } @@ -529,12 +559,8 @@ gtk_action_group_add_toggle_actions_full (GtkActionGroup *action_group, for (i = 0; i < n_entries; i++) { GtkAction *action; - gchar *accel_path; - guint accel_key = 0; - GdkModifierType accel_mods; - GtkStockItem stock_item; - gchar *label; - gchar *tooltip; + const gchar *label; + const gchar *tooltip; if (translate_func) { @@ -562,26 +588,10 @@ gtk_action_group_add_toggle_actions_full (GtkActionGroup *action_group, entries[i].callback, user_data, (GClosureNotify)destroy, 0); - /* set the accel path for the menu item */ - accel_path = g_strconcat ("/", action_group->private_data->name, "/", - entries[i].name, NULL); - - if (entries[i].accelerator) - gtk_accelerator_parse (entries[i].accelerator, &accel_key, &accel_mods); - else if (entries[i].stock_id && - gtk_stock_lookup (entries[i].stock_id, &stock_item)) - { - accel_key = stock_item.keyval; - accel_mods = stock_item.modifier; - } - - if (accel_key) - gtk_accel_map_add_entry (accel_path, accel_key, accel_mods); - - gtk_action_set_accel_path (action, accel_path); - g_free (accel_path); - - gtk_action_group_add_action (action_group, action); + gtk_action_group_add_action_with_accel (action_group, action, + entries[i].name, + entries[i].accelerator, + entries[i].stock_id); g_object_unref (action); } } @@ -661,12 +671,8 @@ gtk_action_group_add_radio_actions_full (GtkActionGroup *action_group, for (i = 0; i < n_entries; i++) { GtkAction *action; - gchar *accel_path; - guint accel_key = 0; - GdkModifierType accel_mods; - GtkStockItem stock_item; - gchar *label; - gchar *tooltip; + const gchar *label; + const gchar *tooltip; if (translate_func) { @@ -695,28 +701,11 @@ gtk_action_group_add_radio_actions_full (GtkActionGroup *action_group, if (value == entries[i].value) gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE); - - /* set the accel path for the menu item */ - accel_path = g_strconcat ("/", - action_group->private_data->name, "/", - entries[i].name, NULL); - - if (entries[i].accelerator) - gtk_accelerator_parse (entries[i].accelerator, &accel_key, &accel_mods); - else if (entries[i].stock_id && - gtk_stock_lookup (entries[i].stock_id, &stock_item)) - { - accel_key = stock_item.keyval; - accel_mods = stock_item.modifier; - } - if (accel_key) - gtk_accel_map_add_entry (accel_path, accel_key, accel_mods); - - gtk_action_set_accel_path (action, accel_path); - g_free (accel_path); - - gtk_action_group_add_action (action_group, action); + gtk_action_group_add_action_with_accel (action_group, action, + entries[i].name, + entries[i].accelerator, + entries[i].stock_id); g_object_unref (action); } diff --git a/gtk/gtkactiongroup.h b/gtk/gtkactiongroup.h index 7d8b4be203..bd4ff94f69 100644 --- a/gtk/gtkactiongroup.h +++ b/gtk/gtkactiongroup.h @@ -74,32 +74,32 @@ struct _GtkActionGroupClass struct _GtkActionEntry { - gchar *name; - gchar *stock_id; - gchar *label; - gchar *accelerator; - gchar *tooltip; + const gchar *name; + const gchar *stock_id; + const gchar *label; + const gchar *accelerator; + const gchar *tooltip; GCallback callback; }; struct _GtkToggleActionEntry { - gchar *name; - gchar *stock_id; - gchar *label; - gchar *accelerator; - gchar *tooltip; + const gchar *name; + const gchar *stock_id; + const gchar *label; + const gchar *accelerator; + const gchar *tooltip; GCallback callback; gboolean is_active; }; struct _GtkRadioActionEntry { - gchar *name; - gchar *stock_id; - gchar *label; - gchar *accelerator; - gchar *tooltip; + const gchar *name; + const gchar *stock_id; + const gchar *label; + const gchar *accelerator; + const gchar *tooltip; gint value; }; @@ -111,6 +111,12 @@ GtkAction *gtk_action_group_get_action (GtkActionGroup * GList *gtk_action_group_list_actions (GtkActionGroup *action_group); void gtk_action_group_add_action (GtkActionGroup *action_group, GtkAction *action); +void gtk_action_group_add_action_with_accel (GtkActionGroup *action_group, + GtkAction *action, + const char *name, + const char *accelerator, + const char *stock_id); + void gtk_action_group_remove_action (GtkActionGroup *action_group, GtkAction *action); void gtk_action_group_add_actions (GtkActionGroup *action_group, -- 2.30.2